package com.wskh.eduCms.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wskh.eduCms.entity.CrmBanner;
import com.wskh.eduCms.mapper.CrmBannerMapper;
import com.wskh.eduCms.service.CrmBannerService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 首页banner表 服务实现类
 * </p>
 *
 * @author wskh
 * @since 2021-10-18
 */
@Service
public class CrmBannerServiceImpl extends ServiceImpl<CrmBannerMapper, CrmBanner> implements CrmBannerService {

    @Override
    public List<CrmBanner> selectIndexList() {

        QueryWrapper<CrmBanner> crmBannerQueryWrapper = new QueryWrapper<>();
        crmBannerQueryWrapper.orderByDesc("id");
        // last方法 凭借sql语句
        crmBannerQueryWrapper.last("limit 2");

        return baseMapper.selectList(crmBannerQueryWrapper);
    }
}
